import type {
  VxeColumnProps,
  VxeGridProps,
  VxeColumnPropTypes
} from "vxe-table";

export enum ACTION_TYPE {
  REFRESH = "refresh",
  UPLOAD = "upload",
  DOWNLOAD = "download",
  PRINT = "print",
  TADD = "t-add",
  ADD = "add",
  TDELETE = "t-delete",

  DETAIL = "detail",
  VIEW = "view",
  DELETE = "delete",
  EDIT = "edit",
  FULLSCREEN = "fullscreen",
  PUTAWAY = "putaway",
  OFFSHELVE = "offshelve",
  TPUTAWAY = "t-putaway",
  TOFFSHELVE = "t-offshelve",
  ISSUED = "issued"
}

export interface ActionsProps {
  key: ACTION_TYPE | string;
  icon?: string;
  name: string;
  status?: "primary" | "success" | "warning" | "danger" | "info" | "";
  disabled?: boolean;
  hidden?: boolean;
  onClick?: Function;
  disableHandle?: Function;
  hiddenHandle?: Function;
  plain?: boolean;
  row?: ObjectProps;
  seq?: number;
}

export type FetchConfig = {
  query?: {
    service: (param: ObjectProps) => Promise<any>;
    param: ObjectProps | Function;
  };
  delete?: {
    service: (param: ObjectProps) => Promise<any>;
    param: ObjectProps | Function;
  };
};

export type vxeColumnConfigType = {
  [key: string]: { slots?: VxeColumnPropTypes.Slots } & VxeColumnProps;
};

export interface PropDefines {
  tableTitle?: string;
  actions?: Array<ACTION_TYPE>;
  showIndex?: boolean;
  isServerPage?: boolean;
  showCheckbox?: boolean;
  showExportBtn?: boolean;
  dataSource?: Array<{ [key: string]: any }>;
  columns?: Array<{ slots?: VxeColumnPropTypes.Slots } & VxeColumnProps>;
  vxeColumnConfig?: vxeColumnConfigType;
  fetchConfig?: FetchConfig;
  topTools?: ActionsProps[];
  operateTools?: ActionsProps[];
  vxeTableConfig?: VxeGridProps<ObjectProps>;
  operateDisableHandle?: {
    [key: ACTION_TYPE | string]: (row: ObjectProps) => boolean;
  };
  // [key: string]: any;
}

export type ObjectProps = Record<string, any>;
